﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

/**
 * 创建时间：2014/11/3 10:57:26
 * 作者：yong.blackcore
 * Email：itblackhole@outlook.com
 * QQ：50404503
 */
namespace CUWo.Common.Entities.WoInterface.HttpJsonResult
{
    [DataContract(Name = "msg")]
    public class JsonResultMessage
    {
        [DataMember(Name = "errMsg")]
        public IList<JsonResultMessageError> MessageErrors { get; set; }

        [DataMember(Name = "promptMsg")]
        public IList<JsonResultMessagePrompt> MessagePrompts { get; set; }

        [DataMember(Name = "warnMsg")]
        public IList<JsonResultMessageWarn> MessageWarns { get; set; }

        public override string ToString()
        {
            StringBuilder output = new StringBuilder();
            if (MessageErrors != null && MessageErrors.Count > 0)
            {
                output.AppendLine("errMsg:[");
                foreach (JsonResultMessageError error in MessageErrors)
                {
                    output.AppendLine(error.ToString());
                }
                output.AppendLine("]");
            }
            else
            {
                output.AppendLine("errMsg:[]");
            }
            //
            if (MessagePrompts != null && MessagePrompts.Count > 0)
            {
                output.AppendLine("promptMsg:[");
                foreach (JsonResultMessagePrompt error in MessagePrompts)
                {
                    output.AppendLine(error.ToString());
                }
                output.AppendLine("]");
            }
            else
            {
                output.AppendLine("promptMsg:[]");
            }
            //
            if (MessageWarns != null && MessageWarns.Count > 0)
            {
                output.AppendLine("warnMsg:[");
                foreach (JsonResultMessageWarn warn in MessageWarns)
                {
                    output.AppendLine(warn.ToString());
                }
                output.AppendLine("]");
            }
            else
            {
                output.AppendLine("warnMsg:[]");
            }
            return output.ToString();
        }
    }
}
